#include "CassiopeiaComponent.h"


CassiopeiaComponent::CassiopeiaComponent()
{
	activeChangedPtr=0;
	active=false;
}

CassiopeiaComponent::~CassiopeiaComponent()
{
}

CCState CassiopeiaComponent::Activate()
{
	if (active)
		return CCState::NoActionNecessary;

	active=true;
	OnActiveChanged();

	return CCState::Successful;
}

CCState CassiopeiaComponent::Deactivate()
{
	if (!active)
		return CCState::NoActionNecessary;

	active=false;
	OnActiveChanged();

	return CCState::Successful;
}

bool CassiopeiaComponent::IsActive()
{
	return active;
}

void CassiopeiaComponent::ToggleActiveState()
{
	if (active)
		Deactivate();
	else
		Activate();
}

void CassiopeiaComponent::ActiveChanged(ACTIVECHANGEDPROC ptr)
{
	this->activeChangedPtr = ptr;
}

void CassiopeiaComponent::OnActiveChanged()
{
	if (activeChangedPtr)
		activeChangedPtr(this, this->active);
}
